package edu.bu.cs673b1s1p3.nextbus.map;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.jdesktop.swingx.mapviewer.GeoPosition;
import org.jdesktop.swingx.mapviewer.Waypoint;

import edu.bu.cs673b1s1p3.nextbus.service.routeconfig.Path;
import edu.bu.cs673b1s1p3.nextbus.service.routeconfig.RouteConfig;
import edu.bu.cs673b1s1p3.nextbus.service.routeconfig.Stop;

/**
 * @author Jimson
 */

public class MapControl implements MapControlInterface {
	MapModel mapModel;
	MapView mapView;
	
	/**
	 * constructor
	 */
	public MapControl(MapModel model) {
		mapModel = model;
		mapView = new MapView(model);
	}
	
	public void createMapView() {
		mapView.createMapView();
	}
	
	public void setCenterPosition(GeoPosition geoPosition) {
		mapModel.getMapViewer().setCenterPosition(geoPosition);
	}
	
	public void setCenterPosition(BigDecimal lat, BigDecimal lon) {
		setCenterPosition(new GeoPosition(lat.doubleValue(), lon.doubleValue()));
	}
	
	public void setZoom(int zoom) {
		mapModel.getMapViewer().setZoom(zoom);
	}
	
	public void setStop(GeoPosition stopPos) {
		mapModel.setStop(stopPos);
	}
	
	public void getStopsNearHome() {
		mapModel.showStopsNearHome();
	}
	
	/**
	 * Adds labels to stops
	 * 
	 * @param stops
	 */
	public void addAllWaypointLabels(List<Stop> stops) {
		for(int i=0; i<stops.size(); i++) {
			mapModel.addWaypointLabel(stops.get(i));
		}
	}
	
	public void getAllOverlays() {
		mapModel.showAllOverlays();
	}
	
	public void clearOverlays() {
		mapModel.clearOverlays();
	}
	
	public void addHomeWaypoint(Waypoint waypoint) {
		mapModel.addHomeWaypoint(waypoint);
	}
	
	public void addWaypoint(Waypoint waypoint) {
		mapModel.addWaypoint(waypoint);
	}
	
	public void addWaypoint(Set<Waypoint> waypoints, List<Stop> stops) {
		mapModel.addWaypoint(waypoints, stops);
	}
	
	public void drawRoute() {
		mapModel.drawRoute();
	}
	
	public void drawRoute(RouteConfig routeConfig, ArrayList<Path> paths) {
		mapModel.drawRoute(routeConfig, paths);
	}

}
